<!--

    Copyright © 2016-2025 The Thingsboard Authors

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<section class="subscription-container">
  <section class="subscription-row flex flex-row items-center justify-between"
    (mouseenter)="onMouseEnter()"
    (mouseleave)="onMouseLeave()">
    <section class="flex max-w-70% flex-[70%] flex-row items-center gap-2">
      <section class="subscription-row-label flex flex-row items-center gap-2">
        <div class="label-color" [style]="{backgroundColor: subscription().configuration.color}"></div>
        <span class="label tb-pointer"
          [matTooltip]="'action.edit' | translate"
          (click)="openSubscriptionDetails($event)">
          {{ subscription().configuration.topicFilter }}
        </span>
      </section>
      <span class="label qos">{{ 'mqtt-client-session.qos' | translate }} {{ subscription().configuration.qos }}</span>
    </section>
    <section>
      <div [class.action-buttons-container]="showActions"
           class="flex flex-row justify-end gap-2 xs:hidden">
        @for (actionDescriptor of hiddenActions; track actionDescriptor) {
          <div
            class="action-buttons" [class.show-buttons]="showActions"
            matTooltipPosition="above"
            matTooltip="{{ actionDescriptor.name }}">
            @if (actionDescriptor.isEnabled(subscription())) {
              <button mat-icon-button
                class="tb-mat-32"
                [disabled]="!actionDescriptor.isEnabled(subscription())"
                (click)="actionDescriptor.onAction($event, subscription())">
                <mat-icon [svgIcon]="actionDescriptor.icon"></mat-icon>
              </button>
            }
          </div>
        }
      </div>
      <div class="hidden flex-row justify-end gap-2 xs:flex">
        <button mat-icon-button
          class="tb-mat-32"
          (click)="$event.stopPropagation()"
          [matMenuTriggerFor]="cellActionsMenu">
          <mat-icon class="home-page-material-icons material-icons">more_vert</mat-icon>
        </button >
        <mat-menu #cellActionsMenu="matMenu" xPosition="before">
          @for (actionDescriptor of hiddenActions; track actionDescriptor) {
            <button mat-menu-item
              [class.!hidden]="!actionDescriptor.isEnabled(subscription())"
              (click)="actionDescriptor.onAction($event, subscription())">
              <tb-icon [style]="actionDescriptor.style">{{actionDescriptor.icon}}</tb-icon>
              <span>{{ actionDescriptor.name }}</span>
            </button>
          }
        </mat-menu>
      </div>
    </section>
  </section>
</section>
